package com.dt.platform.generator.module.oa;

import com.dt.platform.constants.db.OaTables;
import com.dt.platform.constants.enums.oa.MeetingRoomStatusEnum;
import com.dt.platform.domain.oa.MeetingRoomPosition;
import com.dt.platform.domain.oa.meta.FinReimburseItemMeta;
import com.dt.platform.domain.oa.meta.MeetingRoomMeta;
import com.dt.platform.domain.oa.meta.MeetingRoomPositionMeta;
import com.dt.platform.generator.config.Config;
import com.dt.platform.oa.page.FinReimburseItemPageController;
import com.dt.platform.proxy.oa.FinReimburseItemServiceProxy;
import com.dt.platform.proxy.oa.MeetingRoomPositionServiceProxy;
import com.github.foxnic.generator.config.WriteMode;
import org.github.foxnic.web.domain.system.DictItem;
import org.github.foxnic.web.domain.system.meta.DictItemMeta;
import org.github.foxnic.web.proxy.system.DictItemServiceProxy;

public class FinReimburseItemGtr extends BaseCodeGenerator {


    public FinReimburseItemGtr() {
        super(OaTables.OA_FIN_REIMBURSE_ITEM.$TABLE,"616256779512184832");
    }

    public void generateCode() throws Exception {
        System.out.println(this.getClass().getName());

        cfg.getPoClassFile().addSimpleProperty(DictItem.class,"typeDict","typeDict","typeDict");
        cfg.view().field(OaTables.OA_FIN_REIMBURSE_ITEM.ID).basic().hidden(true);

        cfg.view().field(OaTables.OA_FIN_REIMBURSE_ITEM.TYPE);
        cfg.view().search().inputLayout(
                new Object[]{
                        OaTables.OA_FIN_REIMBURSE_ITEM.TYPE,
                }
        );


        cfg.view().search().labelWidth(1,Config.searchLabelWidth);
        cfg.view().search().labelWidth(2,Config.searchLabelWidth);
        cfg.view().search().labelWidth(3,Config.searchLabelWidth);
        cfg.view().search().labelWidth(4,Config.searchLabelWidth);
        cfg.view().search().inputWidth(Config.searchInputWidth);

        cfg.view().field(OaTables.OA_FIN_REIMBURSE_ITEM.AMOUNT).form().validate().required().form().numberInput().defaultValue(0.0).scale(2);

        cfg.view().field(OaTables.OA_FIN_REIMBURSE_ITEM.NOTES).form().textArea().height(150);


        cfg.view().field(OaTables.OA_FIN_REIMBURSE_ITEM.CREATE_TIME).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_REIMBURSE_ITEM.CREATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_REIMBURSE_ITEM.UPDATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_REIMBURSE_ITEM.UPDATE_TIME).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_REIMBURSE_ITEM.OWNER_ID).table().disable(true);
        cfg.view().list().disableBatchDelete();


        cfg.view().field(OaTables.OA_FIN_REIMBURSE_ITEM.TYPE).form().validate().required().form()
           .selectBox().queryApi(DictItemServiceProxy.QUERY_PAGED_LIST+"?dictCode=oa_fin_reimburse_item")
                .paging(true).filter(false).toolbar(false)
                .valueField(DictItemMeta.CODE).
                textField(DictItemMeta.LABEL).
                fillWith(FinReimburseItemMeta.TYPE_DICT).muliti(false);


        cfg.view().list().addJsVariable("OWNER_ID","[[${ownerId}]]","ownerId");
        cfg.view().list().addJsVariable("PAGE_TYPE","[[${pageType}]]","pageType");

        cfg.view().form().addJsVariable("OWNER_ID","[[${ownerId}]]","ownerId");
        cfg.view().form().addJsVariable("PAGE_TYPE","[[${pageType}]]","pageType");

        cfg.view().form().labelWidth(80);
        cfg.view().formWindow().bottomSpace(50);
        cfg.view().formWindow().width(Config.baseFormWidth);
        cfg.view().form().addGroup(null,
                new Object[] {
                        OaTables.OA_FIN_REIMBURSE_ITEM.TYPE,
                        OaTables.OA_FIN_REIMBURSE_ITEM.AMOUNT,
                        OaTables.OA_FIN_REIMBURSE_ITEM.NOTES,
                }
        );

        //文件生成覆盖模式
        cfg.overrides()
                .setServiceIntfAnfImpl(WriteMode.COVER_EXISTS_FILE) //服务与接口
                .setControllerAndAgent(WriteMode.COVER_EXISTS_FILE) //Rest
                .setPageController(WriteMode.IGNORE) //页面控制器
                .setFormPage(WriteMode.COVER_EXISTS_FILE) //表单HTML页
                .setListPage(WriteMode.COVER_EXISTS_FILE)
                .setExtendJsFile(WriteMode.IGNORE); //列表HTML页
        //列表HTML页
        //生成代码
        cfg.buildAll();
    }

    public static void main(String[] args) throws Exception {
        FinReimburseItemGtr g=new FinReimburseItemGtr();
        //生成代码
        g.generateCode();

        //移除之前生成的菜单，视情况执行
//        g.removeByBatchId("471622036347682816");
        //生成菜单
        //
     // g.generateMenu(FinReimburseItemServiceProxy.class, FinReimburseItemPageController.class);
    }

}
